package com.anosine.gpsl.android.presenter;

import com.anosine.gpsl.android.dao.FortifiedDao;
import com.anosine.gpsl.android.entity.SafeStatus;
import com.anosine.gpsl.android.impl.FortifiedDaoImpl;
import com.anosine.gpsl.android.presenter.BasePresenterActivity.OnLoadListener;
import com.anosine.gpsl.android.ui.FortifiedView;
import com.lidroid.xutils.util.LogUtils;

/**
 * @Title: FortifiedPresenter
 * @Package com.anosine.gpsl.android.presenter
 * @Description: 接收impl传递过来的Result解析JSON语句后的数据，并且改为实体后放入View的方法中传递给View，获取登录信息
 * @author: sunny
 * @date: 2015-11-22
 * @version V1.0
 */
public class FortifiedPresenter extends BasePresenterFragment implements OnLoadListener{
	private FortifiedDao dao;
	private FortifiedView view;

	/**
	 * @Title: FortifiedPresenter(FortifiedView view)
	 * @Description: 构造方法，初始化
	 * @param: view
	 * @throws
	 */

	public FortifiedPresenter(FortifiedView view) {
		super();
		this.dao = new FortifiedDaoImpl(this);
		this.view = view;
	}

	/**   
	 * @Title: loadFortified(String is_set_safe, String objectid, String usermd5)
	 * @Description: 设置设防（参数）
	 * @param: usermd5  登录验证串
	 * @param: is_set_safe 设防标记
	 * @param: objectid 车辆id
	 * @return: 无   
	 * @throws   
	 */  

	public void loadFortified(String is_set_safe, String objectid, String usermd5) {
		dao.getFortified(is_set_safe, objectid, usermd5);
	}

	/**
	 * @Title: onLoadStart()
	 * @Description: 重写加载开始方法
	 * @param: 无
	 * @return: 无
	 * @throws
	 */

	@Override
	public void onLoadStart() {
		LogUtils.d("获取设防信息加载中。。");
	}

	/**
	 * @Title: onFailure()
	 * @Description: 重写加载失败方法
	 * @param: 无
	 * @return: 无
	 * @throws
	 */
	@Override
	public void onFailure() {
		LogUtils.d("获取设防信息加载失败。。");
	}

	/**
	 * @Title: onSuccess(Object obj)
	 * @Description: 重写加载成功方法
	 * @param: Object obj
	 * @return: 无
	 * @throws
	 */
	@Override
	public void onSuccess(Object obj) {
		SafeStatus res = (SafeStatus) obj;
		loadFortifiedSuccess(res);
	}

	/**
	 * @Title: loadFortifiedSuccess(SafeStatus res)
	 * @Description: 将传递过来的JSON语句解析后的数据改为实体后放入FortifiedView的方法中传递给View
	 * @param: SafeStatus res
	 * @return: 无
	 * @throws
	 */
	private void loadFortifiedSuccess(SafeStatus res) {
		this.view.setTabFortified(res);
	}
}
